import grace from "../../utils/grace.js"
grace.page({
      data: {
            vc_pwd: '',
            vc_sn: '',
            tips: []
      },
      onLoad: function(options) {
            wx.hideNavigationBarLoading();
      },
      doSubmit: function() {
            let vc_sn = this.$data.vc_sn;
            let vc_pwd = this.$data.vc_pwd;
            if (vc_sn.length == 0) {
                  this.toast('请先填写储值卡号');
                  return;
            }
            if (vc_pwd.length == 0) {
                  this.toast('请先填写储值卡密码');
                  return;
            }
            this.$http.post('api/valuecard/recharge', {
                        vc_sn: vc_sn,
                        vc_pwd: vc_pwd
                  })
                  .then((res) => {
                        this.toast('充值成功！');
                        this.$goBack();
                  })
      },
      inputHandle: function(e) {
            let name = e.target.dataset.name;
            this.$data[name] = e.detail.value;
      }
})